package com.cwx.mychat.openai.service;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.openai.OpenAiAudioSpeechModel;
import org.springframework.ai.openai.OpenAiAudioTranscriptionModel;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.stereotype.Service;

/**
 * 作者： cwx
 * 时间： 2024/12/31 11:45
 * 版本： 1.0
 * 注释：
 */
@Service
public class AIChatService {

    @Resource
    private OpenAiChatModel openAiChatModel;

    @Resource
    private OpenAiAudioTranscriptionModel openAiAudioTranscriptionModel;

    @Resource
    private OpenAiAudioSpeechModel openAiAudioSpeechModel;

    /**
     * 机器人聊天
     * @param message
     * @return
     */
    public String chat(String message){
        return openAiChatModel.call(message);
    }

    /**
     * 文字转语音
     */
    public String textToSpeech(String text){
        byte[] call = openAiAudioSpeechModel.call(text);
        System.out.println(call);
        return call.toString();
    }
}
